package acm.蓝桥16;

import java.util.Scanner;

public class B最大的数 {
    static long maxN = (long) 1e17;
    static int maxM = 100;

    /**
     * dp[i][j]:进行i次1操作，j次2操作的方案数，取最大结果
     * dp[i][j]=max(dp[i-1][j]+op1,dp[i][j-1]+op2)
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long x = sc.nextLong();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int n = getN(x);
        long dfs = dfs(n, a, b, x);
        System.out.println(dfs);
    }

    public static int getN(long x){
        int cnt=0;
        while (x!=0){
            x/=10;
            cnt++;
        }
        return cnt;
    }
    public static long dfs(int i, int a, int b, long x) {
        if (i == 0) {
            return x;
        }
        long res = dfs(i - 1, a, b, x);    //进行0次操作
        for (int c = 1; c <= a && c < 10; c++) {    //进行a操作
            long op1 = op1(i, c, x);
            long cur = dfs(i - 1, a - c, b, op1);
            res = Math.max(cur, res);
        }
        for (int c = 1; c <= b && c < 10; c++) {    //进行b操作
            long op2 = op2(i, c, x);
            long cur = dfs(i - 1, a, b - c, op2);
            res = Math.max(cur, res);
        }

        return res;
    }

    public static long op1(int i, int c, long x) {
        long pow = (long) Math.pow(10, i - 1);
        long upPow = pow * 10;
        long old = x % upPow; //该位置的值
        long v = old / pow; //具体的值
        long newV = (v + c) % 10;
        x = x - pow * v + pow * newV;  //抹去该位
        return x;
    }

    public static long op2(int i, int c, long x) {
        long pow = (long) Math.pow(10, i - 1);
        long upPow = pow * 10;
        long old = x % upPow; //该位置的值
        long v = old / pow; //具体的值
        long newV = (v - c + 10) % 10;
        x = x - pow * v + pow * newV;  //抹去该位
        return x;
    }
}
